<?php

namespace App\Http\Controllers\Api;

use App\Http\Controllers\Controller;
use App\Http\Requests\Cluster;
use App\Http\Requests\UserContext;
use App\Http\Services\ClusterService;
use App\Http\Traits\ResponseJson;

class ClusterController extends Controller
{
    use ResponseJson;

    protected $clusterService;

    public function __construct(ClusterService $clusterService)
    {
        $this->clusterService = $clusterService;
    }

    public function add(UserContext $userContext,Cluster $cluster)
    {
        $data = $this->clusterService->add($userContext,$cluster);
        return $this->returnJson($data);
    }

    public function lists(UserContext $userContext)
    {
        $data = $this->clusterService->lists($userContext);
        return $this->returnJson($data);
    }

    public function dissolve(UserContext $userContext)
    {
        $data = $this->clusterService->dissolve($userContext);
        return $this->returnJson($data);
    }

    public function detail(UserContext $userContext)
    {
        $data = $this->clusterService->detail($userContext);
        return $this->returnJson($data);
    }

    public function memberLists()
    {
        $data = $this->clusterService->memberLists();
        return $this->returnJson($data);
    }

    public function setAdmin(UserContext $userContext)
    {
        $data = $this->clusterService->setAdmin($userContext);
        return $this->returnJson($data);
    }

    public function removeMember(UserContext $userContext)
    {
        $data = $this->clusterService->removeMember($userContext);
        return $this->returnJson($data);
    }

    public function addMember(UserContext $userContext)
    {
        $data = $this->clusterService->addMember($userContext);
        return $this->returnJson($data);
    }

}
